<html>
<head><meta charset="utf-8"><title>Field resolution error · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20error.html">Field resolution error</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="225720520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20error/near/225720520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20error.html#225720520">(Feb 09 2021 at 16:56)</a>:</h4>
<p>Hmm, is this a new bug? <a href="/user_uploads/4715/MkjpQZGs_fvuGwq5jE8IKx_p/screenshot-2021-02-09-175322.png">screenshot-2021-02-09-175322.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/MkjpQZGs_fvuGwq5jE8IKx_p/screenshot-2021-02-09-175322.png" title="screenshot-2021-02-09-175322.png"><img src="/user_uploads/4715/MkjpQZGs_fvuGwq5jE8IKx_p/screenshot-2021-02-09-175322.png"></a></div>



<a name="225720568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20error/near/225720568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20error.html#225720568">(Feb 09 2021 at 16:56)</a>:</h4>
<p><code>block</code> does show up in autocomplete</p>



<a name="225722001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20error/near/225722001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20error.html#225722001">(Feb 09 2021 at 17:04)</a>:</h4>
<p>Not completely new, at least:</p>
<p><a href="/user_uploads/4715/e11-oU6waa6GTE09PJGyGyTb/image.png">image.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/e11-oU6waa6GTE09PJGyGyTb/image.png" title="image.png"><img src="/user_uploads/4715/e11-oU6waa6GTE09PJGyGyTb/image.png"></a></div>



<a name="225722165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20error/near/225722165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20error.html#225722165">(Feb 09 2021 at 17:05)</a>:</h4>
<p>But it doesn't show up in autocomplete for me.</p>



<a name="225731467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20error/near/225731467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20error.html#225731467">(Feb 09 2021 at 18:05)</a>:</h4>
<p>does this actually compile? I'd guess the type of def_map isn't known when you're doing <code>def_map.block</code>. it's inferred later, but too late for the field access</p>



<a name="225731600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20error/near/225731600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20error.html#225731600">(Feb 09 2021 at 18:06)</a>:</h4>
<p>This was reduced from code in nameres, which does compile</p>



<a name="225731828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20error/near/225731828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20error.html#225731828">(Feb 09 2021 at 18:08)</a>:</h4>
<p>Specifically this place: <a href="https://github.com/rust-analyzer/rust-analyzer/blob/98b82859551555a1b0671c75307d56a17aa545b6/crates/hir_def/src/nameres/collector.rs#L1455">https://github.com/rust-analyzer/rust-analyzer/blob/98b82859551555a1b0671c75307d56a17aa545b6/crates/hir_def/src/nameres/collector.rs#L1455</a></p>



<a name="225731985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20error/near/225731985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20error.html#225731985">(Feb 09 2021 at 18:08)</a>:</h4>
<p>that's a bit too reduced then, I think</p>



<a name="225731986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20error/near/225731986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20error.html#225731986">(Feb 09 2021 at 18:08)</a>:</h4>
<p>and also <code>fn crate_root</code> in <code>nameres.rs</code></p>



<a name="225732013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20error/near/225732013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20error.html#225732013">(Feb 09 2021 at 18:09)</a>:</h4>
<p>They both use <code>with_ancestor_maps</code>, maybe that's the culprit</p>



<a name="225732631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20error/near/225732631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20error.html#225732631">(Feb 09 2021 at 18:14)</a>:</h4>
<p>for some reason solving <code>&lt;&amp;DefMap as Index&lt;Idx&lt;ModuleData&gt;&gt;&gt;::Output</code> seems to fail</p>



<a name="225732827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20error/near/225732827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20error.html#225732827">(Feb 09 2021 at 18:15)</a>:</h4>
<p>even though it seems to work in other places</p>



<a name="225733004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20error/near/225733004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20error.html#225733004">(Feb 09 2021 at 18:16)</a>:</h4>
<p>hmm no annotating the map parameter as <code>&amp;DefMap</code> fixes it, so it's probably a closure inference problem after all</p>



<a name="225733275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20error/near/225733275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20error.html#225733275">(Feb 09 2021 at 18:18)</a>:</h4>
<p>making the closure an impl instead of dyn fixes it</p>



<a name="225733611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20error/near/225733611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20error.html#225733611">(Feb 09 2021 at 18:21)</a>:</h4>
<p>hmm ah yeah I think we just don't really handle unifying types with dyn types, and mostly it doesn't matter, but here it does</p>



<a name="225733674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20error/near/225733674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20error.html#225733674">(Feb 09 2021 at 18:21)</a>:</h4>
<p>this will probably only be fixed by switching to Chalk types completely and using their unification code</p>



<a name="225736702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20error/near/225736702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20error.html#225736702">(Feb 09 2021 at 18:40)</a>:</h4>
<p>ah, I see</p>



<a name="225736764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20error/near/225736764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20error.html#225736764">(Feb 09 2021 at 18:41)</a>:</h4>
<p>I was afraid this was related to inner item handling since I noticed it during that time</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>